<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
<#--此ftl中用到的css-->
</#assign>
<#assign js>
<#--此ftl中用到的js-->
<script>
	$(".btn-submit").click(function () {
		// 校验表单合法
		//跑腿分类暂不允许添加子类别
		if($("#serviceClass").val()=='1'){
		    layer.alert("跑腿类别下暂不支持添加二级分类，请选择其他");
		    return ;

		}
        /*var isAdd = $("#isAdd").val();
		if(isAdd=="false"){
            $("#updateAll").value="0"
            layer.confirm('是否更新所有分站该分类定价方式、价格以及描述信息?', {icon: 3, btn: ['全部更新','仅更新系统默认'],title: '提示'}, function (index) {
                $("#updateAll").value="1"
                update(updateAll);
            },function(){
                update(updateAll);

            });

		}else{
            $("#updateAll").value="0"
            update("0");
		}*/
        update("0");


	});

	function update(updateAll){
		var isAdd = $("#isAdd").val();
        var bootstrapValidator = $(".form-edit").data('bootstrapValidator');
        bootstrapValidator.validate();
        if(bootstrapValidator.isValid()){
            $.ajax({
                type: "POST",
                url: "/agentService/edit",
                data: $(".form-edit").serialize(),
                dataType: "JSON",
                success: function(res){

                    if(res.code=='0'){
                        layer.msg(res.message, {time: 2000
                        }, function(){
                            location.href="/agentService/index/${agentService.serviceClass!}";
                        });

					}else{
                        layer.msg(res.message);
					}


                }
            });
        }else{
            return false;
        }

	}


	$('.form-edit').bootstrapValidator({
		message: '请输入有效值',
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		}
	});

</script>
</#assign>
<@layout title="编辑" active="oneclass">
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>
		<#if isAdd>
            新增
        <#else>
            编辑
        </#if>
		<small>二级分类详细信息</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="/"><i class="fa fa-home"></i> 管理后台</a></li>
		<li><a href="/agentService/index"><i class="fa fa-list-ul"></i> 服务业务设置</a></li>
		<li class="active"><i class="fa fa-edit"></i>
		    <#if isAdd>
                新增
            <#else>
                编辑
            </#if>
		</li>
	</ol>
</section>
<!-- Main content -->
<section class="content">
	<div class="row">
		<div class="col-md-12">
			<!-- Default box -->
			<div class="box  box-primary">
				<form class="form-horizontal form-edit" method="post" action="agentService/edit">
					<div class="box-body">
						<input type="hidden" id="id" name="id" value="${agentService.id!}">
						<input type="hidden" id="isAdd" name="isAdd" value="${isAdd?string('true','false')}">
						<input type="hidden" id="updateAll" name="updateAll">
						<input type="hidden" id="serviceCode" name="serviceCode" value="${agentService.serviceCode!}">
						<div class="form-group">
							<label class="col-sm-2 control-label">二级分类名称：</label>
							<div class="col-sm-10">
								<input required placeholder="请输入服务名称" id="serviceName" name="serviceName" class="form-control" type="text" value="${agentService.serviceName!}" >
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">一级分类：</label>
							<div class="col-sm-10">
							    <@my.select id="serviceClass" datas=getDict('SERVICE_CLASS')  value="${agentService.serviceClass!}" defaultValue="请选择" disabled="true"/>
								<input name="serviceClass" value="${agentService.serviceClass!}" type="hidden">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">定价方式：</label>
							<div class="col-sm-10">
							    <@my.select id="priceWay" datas=getDict('PRICE_TYPE')  value="${agentService.priceWay!}" defaultValue="请选择"/>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">定价/上门费：</label>
							<div class="col-sm-10">
								<input required placeholder="定价请输入定价费用/不定价请输入上门费用" id="fee" name="fee" class="form-control" type="text" value="${(agentService.fee?string('0.00'))!}" >
							</div>
						</div>
						<div class="form-group">
                            <label class="col-sm-2 control-label">描述：</label>
                            <div class="col-sm-10">
                                <textarea  placeholder="请输入描述" id="serviceDesc" name="serviceDesc" class="form-control" >${agentService.serviceDesc!}</textarea>
                            </div>
                        </div>


					<div class="box-footer">
						<button type="button" class="btn btn-default btn-back">返回</button>
						<button type="button" class="btn btn-info pull-right btn-submit">提交</button>
					</div>

				</form>
			</div>
			<!-- /.box -->
		</div>
	</div>
</section>
<!-- /.content -->
</@layout>
